<?php
/**
 * +--------------------------------------------------------+
 * @Created by PhpStorm.
 * @Category TestJob.php
 * @Depiction:
 * Author: hwy
 * Date: 2021/2/8  17:18
 * +--------------------------------------------------------+
 */

namespace App\Jobs;

use App\Models\CollectArticle;
use App\Services\CollectArticleService;
use App\Services\SendMailService;
use App\Services\StockArticleService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;

class CollectArticleJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    // 用户类
    protected $data;

    /**
     * 任务可尝试的次数
     *
     * @var int
     */
    public $tries = 5;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($data)
    {
        $this->data = $data;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $insert_data = $this->data;
        CollectArticleService::getInstance()->addData($insert_data);

        return true;
    }

}
